import com.demo.component.UserComponent;
import com.demo.configuration.UserConfiguration;
import com.demo.controller.UserController;
import com.demo.model.User;
import com.demo.repository.UserRepository;
import com.demo.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2023-02-07
 * Time: 18:22
 */
public class App {
    public static void main(String[] args) {




        //获取spring上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

        //从spring上下文对象获取Bean对象
        UserService userService = context.getBean("userService",UserService.class);

        //实例化执行的构造方法和构造方法注入会分别执行
        UserController userController = new UserController(userService,16);
        //使用Bean对象
        userController.sayHello();

        //UserService userService = context.getBean("userService", UserService.class);
        //userService.doService();

        //UserRepository userRepository = context.getBean("userRepository",UserRepository.class);
        //userRepository.doRepository();

        //UserComponent userComponent = context.getBean("userComponent",UserComponent.class);
        //userComponent.doComponent();

        //UserConfiguration userConfiguration = context.getBean("userConfiguration",UserConfiguration.class);
        //userConfiguration.doConfiguration();

        //方法注解是根据方法名获取的,不遵从五大类注解的获取规则
        //User user = context.getBean("Student_user",User.class);
        //System.out.println("userID:" + user.getId() + " | userName:" + user.getName());

    }
}
